const foo2 = function (arrays) {
  const reg = RegExp("^[a-zA-Z0-9]+@[a-zA-Z0-9]+.[a-zA-Z]{2,4}$");

  let newarr = [];

  //遍历数组匹配
  arrays.forEach(function (item) {
    //如果匹配成功，输出元素
    if (reg.test(item)) {
      console.log(item + "\t匹配成功");
      newarr.push(item);
    } else {
      console.log(item + "\t匹配不成功");
    }
  });

  console.log(newarr);
};
